<template>
  <!-- 项目主要情况 -->
    <div class="tobeDone">
        <public-search
                :fields="fields"
                :search-param="form"
                @on-query="onQuery"
                @on-reset="onReset"
        />
        <public-table
                ref="publicTableRef"
                index
                :selection="false"
                :indexWidth="'100'"
                :page="page"
                height="550"
                :tableData="tableData"
                :tableOption.sync="tableOption"
                @page-change="onPageChange"
        >
            <template #buttons="scope">
                <div>
                    <el-button style="margin-left: 0 !important;" class="button_funtion2 m-b5 m-r10" @click="taskManagement(scope.row,'2')">任务执行管理</el-button>
                    <el-button style="margin-left: 0 !important;" class="button_funtion2 m-b5 m-r10" @click="planOptionHandel(scope.row)">投资计划</el-button>
                    <!--               <el-button style="margin-left: 0 !important;" class="m-b5 m-r10" @click="taskManagement(scope.row,'1')">任务管理</el-button>-->
                    <el-button style="margin-left: 0 !important;" class="button_funtion2 m-b5 m-r10" @click="approvalOptionHandel(scope.row)">立项变更</el-button>
                    <el-button style="margin-left: 0 !important;" class="button_funtion2 m-b5 m-r10" @click="flowOptionHandel(scope.row)">现金流量表</el-button>
                    <el-button style="margin-left: 0 !important;" class="button_edit m-b5" @click="viewOptionHandel(scope.row)">查看</el-button>
                </div>
            </template>
        </public-table>
    </div>
</template>

<script setup>
import {onMounted, reactive, ref} from 'vue'
import PublicTable from "@/components/PublicTable";
import PublicSearch from "@/components/PublicSearch";
import {tableCommonFun} from "@/hooks/tableCommon";


const interfaceConfig = reactive({
    fileName:'project',
    apiPath:'designProject.getDesignProjectList',
});

const exportConfig = reactive({
    fileName:'investment',
    apiPath:'projectSetApi.exportProjectSet',
    tableName:'项目集表'
});

/**
 * 默认参数
 * @type {UnwrapNestedRefs<{prepareStatus: number}>}
 */
const defaultParameters = reactive({

});

const {
    form,
    page,
    tableOption,
    tableData,
    onQuery,
    onReset,
    onPageChange,
    getData,
    onExport
}  = tableCommonFun(interfaceConfig,exportConfig,defaultParameters);

form.value = {
    projectQuery:'',
    isGovernment:'',
    typeOfBusiness:''
}

const fields = ref([
    {   type:'input',
        label:'项目名称',
        key:'projectQuery',
        placeholder:'请输入项目名称',
        clearable:true
    },
    {
        type:'select',
        label:'资金类别',
        key:'isGovernment',
        placeholder:'请选择资金类别',
        clearable:true,
        options:{
            labelKey:'label',
            valueKey:'value',
            list:[
                {
                    value: '',
                    label: "全部",
                },
                {
                    value: '0',
                    label: "自投",
                },
                {
                    value: '1',
                    label: "政府投资",
                },
            ]
        }
    },
    {
        type:'select',
        label:'业态',
        key:'typeOfBusiness',
        placeholder:'请选择业态',
        clearable:true,
        options:{
            labelKey:'label',
            valueKey:'value',
            list:[
                {
                    value: '',
                    label: "全部",
                },
                {
                    value: '1',
                    label: "养老",
                },
                {
                    value: '2',
                    label: "教育",
                },
                {
                    value: '3',
                    label: "医疗",
                },
                {
                    value: '4',
                    label: "农贸",
                },
                {
                    value: '5',
                    label: "综合体",
                },
                {
                    value: '6',
                    label: "文&体",
                },
                {
                    value: '7',
                    label: "绿道",
                },
                {
                    value: '8',
                    label: "子公司",
                },
                {
                    value: '20',
                    label: "其他",
                },
            ]
        }
    },
]);

tableOption.value = [
    { label: "项目名称", prop: "projectName", minWidth: 100 },
    { label: "总面积(m²)", prop: "projectArea", minWidth: 100 },
    { label: "立项时间", prop: "projectApplyTime", minWidth: 100 },
    { label: "投资额", prop: "projectAmount", minWidth: 100 },
    { label: "预算控制价", prop: "budgetControlPrice", minWidth: 100 },
    {
        label: "资金类别", prop: "isGovernment", formatter: (val) => {
            return {'0':'自投','1':'政府投资'}[val];
        }, minWidth: 100
    },
    { label: "业态", prop: "typeOfBusiness", formatter: (val) => {
            return {'1':'养老','2':'教育','3':'医疗','4':'农贸','5':'综合体','6':'绿道','7':'文体','8':'子公司','9':'其他',}[val];
        }, minWidth: 100},
   /* {
        label: '操作',
        slot: true,
        width: 400,
        overHidden: false,
        slotName: 'buttons'
    },*/
];

onMounted(()=>{
    getData({
        pageNum:1,
        pageSize:10,
        param:{
            ...form.value
        }
    });
})
</script>

<style lang="scss" scoped>
.tobeDone {
  width: 100%;
  height: 100%;
}
</style>
